home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / curspriv.h < prev    next >
C/C++ Source or Header  |  1993-10-30  |  11KB  |  332 lines

  1. /*
  2. * $Header: C:\CURSES\RCS\curspriv.h 2.1 1993/06/18 20:18:46 MH Rel MH $
  3. *
  4. *                          CURSPRIV.H
  5. *
  6. * Header file for definitions and declarations for the
  7. * PDCurses package. These definitions should not be generally
  8. * accessible to programmers, but are provided if the applications
  9. * programmer decides to make the decision in favor of speed on a
  10. * PC over portability.
  11. *
  12. * Revision History:
  13. * Frotz 1.5Beta 900714  Added many levels of compiler support.
  14. *                       Added mixed prototypes for all "internal" routines.
  15. *                       Removed all assembly language.  Added EGA/VGA
  16. *                       support.  Converted all #ifdef to #if in all
  17. *                       modules except CURSES.H and CURSPRIV.H.
  18. *                       Always include ASSERT.H.  Added support for an
  19. *                       external malloc(), calloc() and free().
  20. *                       Added support for FAST_VIDEO (direct-memory writes).
  21. *                       Added various memory model support (for FAST_VIDEO).
  22. *                       Added much of the December 1988 X/Open Curses
  23. *                       specification.
  24. * bl    1.3     881005  All modules lint-checked with MSC '-W3' and turbo'C'
  25. *                       '-w -w-pro' switches.
  26. * bl    1.2     881002  Support (by #ifdef UCMASM) for uppercase-only
  27. *                       assembly routine names. If UCMASM if defined,
  28. *                       all assembler names are #defined as upper case.
  29. *                       Not needed if you do "MASM /MX. Also missing
  30. *                       declaration of cursesscroll(). Fixes thanks to
  31. *                       N.D. Pentcheff
  32. * bl    1.1     880306  Add _chadd() for raw output routines.
  33. * bl    1.0     870515  Release.
  34. *
  35. */
  36.  
  37. #ifndef __CURSES_INTERNALS__
  38. #define __CURSES_INTERNALS__
  39.  
  40. /* Always include... */
  41. #include <assert.h>
  42.  
  43.  
  44.  
  45. /*----------------------------------------------------------------------
  46. *       MEMORY MODEL SUPPORT:
  47. *
  48. *       MODELS
  49. *               TINY            cs,ds,ss all in 1 segment (not enough memory!)
  50. *               SMALL           cs:1 segment,           ds:1 segment
  51. *               MEDIUM          cs:many segments        ds:1 segment
  52. *               COMPACT         cs:1 segment,           ds:many segments
  53. *               LARGE           cs:many segments        ds:many segments
  54. *               HUGE            cs:many segments        ds:segments > 64K
  55. */
  56. #ifdef  __TINY__
  57. #  define SMALL 1
  58. #endif
  59. #ifdef  __SMALL__
  60. #  define SMALL 1
  61. #endif
  62. #ifdef  __MEDIUM__
  63. #  define MEDIUM 1
  64. #endif
  65. #ifdef  __COMPACT__
  66. #  define COMPACT 1
  67. #endif
  68. #ifdef  __LARGE__
  69. #  define LARGE 1
  70. #endif
  71. #ifdef  __HUGE__
  72. #  define HUGE 1
  73. #endif
  74.  
  75.  
  76. /*----------------------------------------------------------------------
  77. *       OPERATING SYSTEM SUPPORT:
  78. *
  79. *               DOS             The one we all know and love:-}
  80. *               OS/2            The new kid on the block.
  81. *               FLEXOS          A Real-time, protected-mode OS from
  82. *                               Digital Research, Inc.
  83. *                (AKA, the 4680 from IBM...)
  84. */
  85.  
  86. /*----------------------------------------*/
  87. #ifdef  DOS
  88. #  define FAST_VIDEO 1          /* We can write directly to the screen. */
  89.    typedef union REGS Regs;
  90.    extern Regs regs;
  91. #  ifdef GO32
  92. #    define _FAR_POINTER(s,o)    (0xe0000000 + s*16 + o)
  93. #    define _FP_SEGMENT(p)        (unsigned short)((((long)fp) >> 4) & 0xffff)
  94. #    define _FP_OFFSET(p)        ((unsigned short)fp & 0x000f)
  95. #  else
  96. #    ifdef __TURBOC__
  97. /*#      define _FAR_POINTER(s,o)    ((unsigned long)s * 16 + (unsigned long)o)*/
  98. #      define _FAR_POINTER(s,o)    MK_FP(s,o)
  99. #    else
  100. #      define _FAR_POINTER(s,o)    (((long)s << 16) | (long)o)
  101. #    endif
  102. #    define _FP_SEGMENT(p)        (unsigned short)(((long)fp) >> 4)
  103. #    define _FP_OFFSET(p)        ((unsigned short)fp & 0x000f)
  104. #  endif
  105.  
  106. #  ifdef GO32
  107.      unsigned char getdosmembyte (int offs);    /* see: private\_dosmem.c */
  108.      unsigned short getdosmemword (int offs);
  109.      void setdosmembyte (int offs, unsigned char b);
  110.      void setdosmemword (int offs, unsigned short w);
  111. #  else
  112. #    if SMALL || MEDIUM || MSC
  113. #      define getdosmembyte(offs)    (*((unsigned char far *) _FAR_POINTER(0,offs)))
  114. #      define getdosmemword(offs)    (*((unsigned short far *) _FAR_POINTER(0,offs)))
  115. #      define setdosmembyte(offs,x)  (*((unsigned char far *) _FAR_POINTER(0,offs)) = (x))
  116. #      define setdosmemword(offs,x)  (*((unsigned short far *) _FAR_POINTER(0,offs)) = (x))
  117. #    else
  118. #      define getdosmembyte(offs)    (*((unsigned char *) _FAR_POINTER(0,offs)))
  119. #      define getdosmemword(offs)    (*((unsigned short *) _FAR_POINTER(0,offs)))
  120. #      define setdosmembyte(offs,x)  (*((unsigned char *) _FAR_POINTER(0,offs)) = (x))
  121. #      define setdosmemword(offs,x)  (*((unsigned short *) _FAR_POINTER(0,offs)) = (x))
  122. #    endif
  123. #  endif
  124. #endif
  125.  
  126. /*----------------------------------------*/
  127. #ifdef  FLEXOS
  128. #  define FAST_VIDEO 1          /* We can use scopy()   */
  129. #  define GMODE  0 /* KLUDGE ALERT!
  130.                    * GMODE == 0 defines character mode structures in FLEXTAB.H.
  131.                    * GMODE == 1 defines graphics  mode structures in FLEXTAB.H.
  132.                    */
  133. #include <flextab.h>
  134. extern VIRCON vir;
  135. #endif
  136.  
  137.  
  138.  
  139.  
  140. /*----------------------------------------------------------------------
  141. *       MALLOC DEBUGGING SUPPORT:
  142. *
  143. *       Set EMALLOC and EMALLOC_MAGIC in order to use your private
  144. *       versions of malloc(), calloc(), and free().  This can help,
  145. *       but not solve, your malloc problems when debugging...
  146. *
  147. */
  148. #ifndef    INTERNAL
  149. #  define EMALLOC 0             /* Disable External Malloc            */
  150. #else
  151. #  define EMALLOC 0             /* Enable/Disable External Malloc       */
  152. #  define EMALLOC_MAGIC  0x0C0C /* Our magic indicator that we should   */
  153.                                 /* use our external malloc rather than  */
  154.                                 /* the runtime's malloc.                */
  155. #endif
  156.  
  157.  
  158. /*----------------------------------------------------------------------*/
  159. /* window properties */
  160. #define _SUBWIN         0x01    /* window is a subwindow            */
  161. #define _ENDLINE        0x02    /* last winline is last screen line */
  162. #define _FULLWIN        0x04    /* window fills screen              */
  163. #define _SCROLLWIN      0x08    /* window lwr rgt is screen lwr rgt */
  164. #define _PAD            0x10    /* X/Open Pad.                      */
  165.  
  166.  
  167.  
  168.  
  169. /*----------------------------------------------------------------------*/
  170. /* Miscellaneous */
  171. #define _INBUFSIZ       512     /* size of terminal input buffer */
  172. #define _NO_CHANGE      -1      /* flags line edge unchanged     */
  173.  
  174.  
  175.  
  176.  
  177. /* @@@ THESE SHOULD BE INDIVIDUAL FUNCTIONS, NOT MACROS! */
  178. #define _BCHAR          0x03    /* Break char        (^C)         */
  179. #define _ECHAR          0x08    /* Erase char        (^H)         */
  180. #define _DWCHAR         0x17    /* Delete Word char (^W)         */
  181. #define _DLCHAR         0x15    /* Delete Line char (^U)         */
  182. #define _GOCHAR         0x11    /* ^Q character                  */
  183. #define _PRINTCHAR      0x10    /* ^P character                  */
  184. #define _STOPCHAR       0x13    /* ^S character                  */
  185. #define  NUNGETCH       20      /* max # chars to ungetch()      */
  186.  
  187.  
  188.  
  189.  
  190. /* Setmode stuff */
  191. struct cttyset
  192. {
  193.     bool    been_set;
  194.     SCREEN    saved;
  195. };
  196.  
  197. extern struct cttyset c_sh_tty;         /* tty modes for shell_mode */
  198. extern struct cttyset c_pr_tty;         /* tty modes for prog_mode  */
  199. extern struct cttyset c_save_tty;
  200. extern struct cttyset c_save_trm;
  201.  
  202. /* Printscan stuff */
  203. extern char c_printscanbuf[];           /* buffer used during I/O */
  204.  
  205. /* tracing flag */
  206. extern bool trace_on;
  207.  
  208. /* Strget stuff */
  209. extern char*    c_strbeg;
  210.  
  211. /* doupdate stuff */
  212. extern WINDOW*  twin;                   /* used by many routines */
  213.  
  214. /* Monitor (terminal) type information */
  215. #define _NONE           0x00
  216. #define _MDA            0x01
  217. #define _CGA            0x02
  218. #define _EGACOLOR       0x04
  219. #define _EGAMONO        0x05
  220. #define _VGACOLOR       0x07
  221. #define _VGAMONO        0x08
  222. #define _MCGACOLOR      0x0a
  223. #define _MCGAMONO       0x0b
  224. #define _FLEXOS         0x20            /* A Flexos console */
  225. #define _MDS_GENIUS     0x30
  226. #define _UNIX_COLOR     0x40
  227. #define _UNIX_MONO      0x41
  228.  
  229. /* Text-mode font size information */
  230. #define _FONT8  8
  231. #define _FONT14 14
  232. #define _FONT15 15              /* GENIUS */
  233. #define _FONT16 16
  234.  
  235.  
  236. /*----------------------------------------------------------------------
  237. *       ANSI C prototypes.  Be sure that your compiler conditional
  238. *       compilation definitions above define ANSI to be non-zero
  239. *       if you compiler supports prototypes.
  240. */
  241. #ifdef     ANSI
  242. #  ifdef  CPLUSPLUS
  243.      extern "C" {
  244. #  endif
  245. bool    PDC_check_bios_key( void );
  246. bool    PDC_get_ctrl_break( void );
  247. bool    PDC_transform_line( int );
  248. chtype    PDC_validchar( chtype );
  249. int    PDC_backchar( WINDOW*, char*, int* );
  250. int    PDC_scr_open( SCREEN*, bool );
  251. int    PDC_scr_close( void );
  252. int    PDC_get_cursor_pos( int*, int* );
  253. int    PDC_get_cur_row( void );
  254. int    PDC_get_cur_col( void );
  255. int    PDC_get_columns( void );
  256. int    PDC_scroll( int, int, int, int, int, chtype );
  257. int    PDC_set_ctrl_break( bool );
  258. int    PDC_clr_update( WINDOW* );
  259. int    PDC_chadd( WINDOW*, chtype, bool, bool );
  260. int    PDC_chins( WINDOW*, chtype, bool );
  261. #ifdef     OS2
  262. VIOCONFIGINFO    PDC_query_adapter_type( void );
  263. VIOMODEINFO    PDC_get_scrn_mode( void );
  264. int    PDC_set_scrn_mode( VIOMODEINFO );
  265. bool    PDC_scrn_modes_equal (VIOMODEINFO, VIOMODEINFO);
  266. #else
  267. int    PDC_query_adapter_type( void );
  268. int    PDC_get_scrn_mode( void );
  269. int    PDC_set_scrn_mode( int );
  270. bool    PDC_scrn_modes_equal (int, int);
  271. #endif
  272. int    PDC_get_font( void );
  273. int    PDC_set_font( int );
  274. int    PDC_set_80x25( void );
  275. int    PDC_fix_cursor( int );
  276. int    PDC_get_rows( void );
  277. int    PDC_set_rows( int );
  278. int    PDC_putchar( chtype );
  279. int    PDC_clr_scrn( WINDOW* );
  280. int    PDC_gattr( void );
  281. int    PDC_gotoxy( int, int );
  282. int    PDC_print( int, int, int );
  283. int    PDC_chg_attr( WINDOW*, chtype, int, int, int, int );
  284. int    PDC_split_plane( WINDOW*, char*, char*, int, int, int, int );
  285. int    PDC_sanity_check( int );
  286. int    PDC_get_cursor_mode( void );
  287. int    PDC_set_cursor_mode( int, int );
  288. int    PDC_get_bios_key( void );
  289. int    PDC_putc( chtype, chtype );
  290. int    PDC_putctty( chtype, chtype );
  291. int    PDC_rawgetch( void );
  292. int    PDC_sysgetch( void );
  293. int    PDC_copy_win( WINDOW *,WINDOW *,int,int,int,int,int,int,int,int,bool );
  294. void    PDC_usleep( long );
  295. WINDOW*    PDC_makenew( int, int, int, int );
  296. int    PDC_newline( WINDOW*, int );
  297.  
  298. #ifdef    FLEXOS
  299. int    PDC_flexos_8bitmode( void );
  300. int    PDC_flexos_16bitmode( void );
  301. char*    PDC_flexos_gname( void );
  302. #endif
  303.  
  304. #ifdef UNIX
  305. int    PDC_kbhit(void);
  306. int    PDC_setup_keys(void);
  307. #endif
  308.  
  309. #ifdef PDCDEBUG
  310. void    PDC_debug( char*,... );
  311. #endif
  312.  
  313. #ifdef    REGISTERWINDOWS
  314. bool    PDC_inswin( WINDOW*, WINDOW* );
  315. int    PDC_addtail( WINDOW* );
  316. int    PDC_addwin( WINDOW*, WINDOW* );
  317. int    PDC_rmwin( WINDOW* );
  318. WINDS*    PDC_findwin( WINDOW* );
  319. #endif
  320. #  ifdef  CPLUSPLUS
  321.      }
  322. #  endif
  323. #endif
  324.  
  325. #define MAX_ATRTAB    272
  326.  
  327. /* internal macros for attributes */
  328. #define chtype_attr(ch)  ((atrtab[((ch >> 8) & 0xFF)] << 8) & A_ATTRIBUTES)
  329. #define phys_attr(ch)    (atrtab[((ch >> 8) & 0xFF)])
  330.  
  331. #endif /* __CURSES_INTERNALS__*/
  332.